import { reactive } from 'vue'

export interface IRole {
    type?: string,
    id: string | number,
    name: string,
    auth: string,
    ord: string | number,
}

export default function useRoleModel() {
    //初始化数据
    const iRoleModel = (): IRole => {
        return {
            type: '',
            id: 0,
            name: '',
            auth: '',
            ord: 0,
        }
    }

    // 角色验证规则
    const roleRules = reactive({
        name: [{
            required: true,
            message: '请角色名称！',
            trigger: 'blur',
        }, {
            max: 32,
            message: '最大长度32位',
            trigger: 'blur'
        }],
        ord: [{
            required: true,
            pattern: /^(0|[1-9][0-9]*)$/,
            message: '请填写数字！',
            trigger: 'blur',
        }]
    })


    return { iRoleModel, roleRules }
}
